fix: repair failing tests and type errors across api and shared packages - #117
Open
stooit wants to merge 1 commit into
Open
fix: repair failing tests and type errors across api and shared packages#117stooit wants to merge 1 commit into
stooit wants to merge 1 commit into
Conversation
- Implement paginate() stub in shared package with slicing, total, totalPages, and out-of-range/empty handling - Rename User.userName -> username to match test contract - Add missing badRequest import in users route - Fix case-sensitivity bug in auth middleware public-method allow-list - Wire up bun-types in tsconfig to resolve bun:test and process types
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes all failing tests and TypeScript errors in the multi-package repo. Baseline was 9 failing tests and 14 type errors; now 22 pass / 0 fail and
tsc --noEmitis clean (exit 0).Changes
packages/shared/src/utils/pagination.ts— Implemented thepaginate<T>()stub per the test contract: page slicing,total,totalPages(Math.ceil(total/pageSize), so0for empty), out-of-range pages return an empty slice, empty-array handling. Params clamped to a minimum of 1 and coerced against non-finite input.packages/shared/src/types.ts— RenamedUser.userName→usernameto match the field name the tests assert.packages/api/src/routes/users.ts— Added the missingbadRequestimport (from../lib/errors), fixing the POST /users 400-on-missing-fields path.packages/api/src/middleware/auth.ts— Fixed a case-sensitivity bug in the public-method allow-list. Now normalises the incoming method withtoUpperCase()against aSet(["GET","POST"]), soGET/POSTon/usersare public regardless of casing andDELETEstill 401s.tsconfig.json— Added"types": ["bun-types"](already present innode_modules, no new dependency) to resolveCannot find module 'bun:test'andCannot find name 'process'.Verification
Constraints honoured
bun-typeswas already installed).Notes / assumptions
userNamevsusername), the non-test source was changed to match the tests, per instructions.POST /usersunauthenticated, which the tests deliberately require. This permits anonymous user-record creation and email collection — worth a security review before this pattern reaches production, but it was left as the tests mandate.